/*
    Borealis Library
    A library of commonly used hydrolocial modeling building blocks

    Copyright (C) 2008  Chris Marsh

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "ConcurrentMatrix_UnitTest.h"

CPPUNIT_TEST_SUITE_REGISTRATION( ConcurrentMatrixTest );

void ConcurrentMatrixTest::TestParenthesisOverload()
{
	/*
	The matrix should look like:

	[ 1  2  3 ]
	[ 4  5  6 ]
	[ 7  8  9 ]
	[ 10 11 12]
	*/

	int total = 1;

	for(int i = 0; i<4;i++)
	{
		for(int j = 0;j<3;j++)
		{
			((*matrix))(i,j) = total++;
		}
	}

	CPPUNIT_ASSERT((*matrix)(0,0) == 1);
	CPPUNIT_ASSERT((*matrix)(0,1) == 2);
	CPPUNIT_ASSERT((*matrix)(0,2) == 3);

	CPPUNIT_ASSERT((*matrix)(1,0) == 4);
	CPPUNIT_ASSERT((*matrix)(1,1) == 5);
	CPPUNIT_ASSERT((*matrix)(1,2) == 6);

	CPPUNIT_ASSERT((*matrix)(2,0) == 7);
	CPPUNIT_ASSERT((*matrix)(2,1) == 8);
	CPPUNIT_ASSERT((*matrix)(2,2) == 9);

	CPPUNIT_ASSERT((*matrix)(3,0) == 10);
	CPPUNIT_ASSERT((*matrix)(3,1) == 11);
	CPPUNIT_ASSERT((*matrix)(3,2) == 12);



}

void ConcurrentMatrixTest::setUp()
{
	matrix = new Borealis::Concurrent2DArray<int>(4,3);
}

void ConcurrentMatrixTest::tearDown()
{

	delete matrix;
}

void ConcurrentMatrixTest::TestOutOfBounds()
{
	(*matrix)(4,4);
	(*matrix)(-1,-3);
}

